package com.example.framework;

import org.openqa.selenium.By;

import com.example.tests.GroupFields;

public class GroupHelper extends BaseHelper {

	public GroupHelper(ApplicationManager manager) {
		super(manager);
	}

	public void createGroup(GroupFields group) {
		click(By.name("new"));
		fillInGroupDetails(group);
		click(By.name("submit"));
	}
	
	public void editGroup(GroupFields group) {
		click(By.cssSelector("input[name='selected[]']:nth-of-type(1)"));
		click(By.name("edit"));
		fillInGroupDetails(group);
		click(By.name("update"));
	}
	
	public void fillInGroupDetails(GroupFields group) {
		type(By.name("group_name"), group.getName());
		type(By.name("group_header"), group.getHeader());
		type(By.name("group_footer"), group.getFooter());
	}
	
	public void deleteGroup() {
		click(By.cssSelector("input[name='selected[]']:nth-of-type(1)"));
		click(By.name("delete"));
	}

	public void gotoGroupPage() {
		click(By.linkText("group page"));
	}

}
